@import "../../support";
// The legacy support threshold for has-layout.
// Defaults to the $critical-usage-threshold.
$has-layout-support-threshold: $critical-usage-threshold !default;

// The `zoom` approach generates less CSS but does not validate.
// Set this to `block` to use the display-property to hack the
// element to gain layout.
$default-has-layout-approach: zoom !default;

// This mixin causes an element matching the selector
// to gain the "hasLayout" property in internet explorer.
// More information on [hasLayout](http://reference.sitepoint.com/css/haslayout).
@mixin has-layout($approach: $default-has-layout-approach) {
  @if support-legacy-browser("ie", "7", $threshold: $has-layout-support-threshold) {
    @if $approach == zoom {
      @include has-layout-zoom;
    } @else if $approach == block {
      @include has-layout-block;
    } @else {
      @warn "Unknown has-layout approach: #{$approach}";
      @include has-layout-zoom;
    }
  }
}

@mixin has-layout-zoom {
  @if support-legacy-browser("ie", "7", $threshold: $has-layout-support-threshold) {
    *zoom: 1;
  }
}

@mixin has-layout-block {
  @if support-legacy-browser("ie", "7", $threshold: $has-layout-support-threshold) {
    // This makes ie6 get layout
    display: inline-block;
    // and this puts it back to block
    & { display: block; }
  }
}


// The legacy support threshold for IE6 attribute hack.
// Defaults to the $critical-usage-threshold.
$ie6-attribute-hack-support-threshold: $critical-usage-threshold !default;

// A hack to supply IE6 (and below) with a different property value.
// [Read more](http://www.cssportal.com/css-hacks/#in_css-important).
@mixin bang-hack($property, $value, $ie6-value) {
  @if support-legacy-browser("ie", "6", $threshold: $ie6-attribute-hack-support-threshold) {
    @warn "it's recommended to use the underscore-hack() mixin instead of bang-hack()";
    #{$property}: #{$value} !important;
    #{$property}: #{$ie6-value};
  }
}

// A hack to supply IE6 (and below) with a different property value.
// [Read more](http://www.paulirish.com/2009/browser-specific-css-hacks/)
@mixin underscore-hack($property, $value, $ie6-value) {
  @if support-legacy-browser("ie", "6", $threshold: $ie6-attribute-hack-support-threshold) {
    #{$property}: #{$value};
    _#{$property}: #{$ie6-value};
  }
}
